package xyz.esion.blog.controller.manage;

import com.ejlchina.searcher.BeanSearcher;
import com.ejlchina.searcher.SearchResult;
import com.ejlchina.searcher.util.MapUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import xyz.esion.blog.entity.Dict;
import xyz.esion.blog.service.DictService;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author Esion
 * @since 2021/12/4
 */
@RestController
@RequestMapping("manage/api/dict")
@RequiredArgsConstructor
public class DictController {

    private final DictService dictService;
    private final BeanSearcher beanSearcher;

    @GetMapping
    public SearchResult<Dict> index(HttpServletRequest request) {
        Map<String, Object> params = MapUtils.flat(request.getParameterMap());
        params.put("isDelete", 0);
        // 这里只写一行代码
        return beanSearcher.search(Dict.class, params);
    }

}
